package org.aileen.trans.controller;


import lombok.extern.slf4j.Slf4j;
import org.aileen.trans.service.LogService;
import org.aileen.trans.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@Slf4j
@RequestMapping("/trans2")
@RestController
public class TransController2 {

    @Autowired
    private UserService userService;

    @Autowired
    private LogService logService;

    /**
     * 事务回滚
     * @param name
     * @param password
     * @return
     */
    @Transactional
    @RequestMapping("/r1")
    public Boolean registry(String name , String password){
        Integer result = userService.insertUser(name,password);
        log.info("用户表数据影响行数: " + result );


        Integer logCount = logService.insertLog(name,"registry");
        log.info("日志表影响行数: " + logCount);
        return true;
    }

}












